<?php
namespace app\common\model;

use think\Db;
use think\Model;

class ShouyeReserve extends Model
{
	protected $insert = ['publish_time'];

    /**
     * 处理时间
     * @return bool|string
     */
    protected function setPublishTimeAttr()
    {
        return date('Y-m-d H:i:s');
    }

    /**
     * 获得预留信息列表
     * @return int
     */
    public function getReserveList($keyword,$page)
    {
    	$map = [];
    	if (!empty($keyword)) {
            $map['name'] = ['like', "%{$keyword}%"];
        }
    	$newslist = $this->where($map)->order(['create_time' => 'DESC'])->paginate(10, false, ['page' => $page]);
    	return $newslist;
    }

    /**
     * 获得单个预留信息
     * @return int
     */
    public function getReserveInfo($id)
    {
        $newslist = $this->where('id',$id)->find();
        return $newslist;
    }

}